package com.example.slidingmenue;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity{

    private LinearLayout mLayout;
    private LinearLayout mLayout1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //按钮
        ImageView imageView = (ImageView) findViewById(R.id.img);
        ImageView imageView1 = (ImageView) findViewById(R.id.img2);

        //两个菜单布局
        mLayout = (LinearLayout) findViewById(R.id.menu);
        mLayout1 = (LinearLayout) findViewById(R.id.menu2);

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "接收到了-----", Toast.LENGTH_SHORT).show();
                mLayout.animate().translationX(mLayout.getMeasuredWidth()).setDuration(500).start();
            }
        });

        imageView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(MainActivity.this, "接收到了吗", Toast.LENGTH_SHORT).show();
                mLayout.animate().translationX(-mLayout1.getMeasuredWidth()).setDuration(500).start();
            }
        });
    }
}
